// -----------------------------------------------------------------------
// <copyright file="ResultsImplementationList.cs" company="VDC-IT" author="LTDUC">
//      Copyright (c) VDC-IT. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace VDC.VONE.ENTITIES
{
    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using AdCom.Utility;
    using VDC.COMMON;
    
    /// <summary>
    /// Class ResultsImplementationList
    /// </summary>
    public class ResultsImplementationList
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultsImplementationList" /> class
        /// </summary>
        public ResultsImplementationList()
        {
            this.ResultsImplementationListId = 0;
            this.Name = string.Empty;
        }

        /// <summary>
        /// Gets or sets ResultsImplementationListId
        /// </summary>
        public int ResultsImplementationListId { get; set; }

        /// <summary>
        /// Gets or sets Name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets ProfileTypes
        /// </summary>
        public IList<ProfileType> ProfileTypes
        {
            get
            {
                try
                {
                    IList<ProfileType> lstProfileType = new List<ProfileType>();
                    var reader = SqlDataHelper.ExecuteReader(string.Format(Constants.StorepProcedure.VOneProfileTypeGetByResultsImplementationListId, this.ResultsImplementationListId));
                    while (reader.Read())
                    {
                        ProfileType profileType = new ProfileType();
                        if (!reader.IsDBNull(0))
                        {
                            profileType.ProfileTypeId = reader.GetInt32(0);
                        }

                        if (!reader.IsDBNull(1))
                        {
                            profileType.WorkflowId = reader.GetInt32(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            profileType.DepartmentId = reader.GetInt32(2);
                        }

                        if (!reader.IsDBNull(3))
                        {
                            profileType.ProfileTypeGroupId = reader.GetInt32(3);
                        }

                        if (!reader.IsDBNull(4))
                        {
                            profileType.ImplementationListId = reader.GetInt32(4);
                        }

                        if (!reader.IsDBNull(5))
                        {
                            profileType.ResultsImplementationListId = reader.GetInt32(5);
                        }

                        if (!reader.IsDBNull(6))
                        {
                            profileType.Code = reader.GetString(6);
                        }

                        if (!reader.IsDBNull(7))
                        {
                            profileType.Name = reader.GetString(7);
                        }

                        if (!reader.IsDBNull(8))
                        {
                            profileType.AmountProfile = reader.GetInt32(8);
                        }

                        if (!reader.IsDBNull(9))
                        {
                            profileType.ResolveDays = reader.GetInt32(9);
                        }

                        if (!reader.IsDBNull(10))
                        {
                            profileType.Fees = reader.GetDecimal(10);
                        }

                        lstProfileType.Add(profileType);
                    }

                    reader.Close();
                    reader.Dispose();
                    return lstProfileType;
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }
    }
}
